#include "bullet.h"

bullet::bullet()
{
    m_Bullet1.load(":/picture/bullet1.png");
    m_Bulletboss.load(":/picture/bossbullet.png");
    m_bullet2.load(":/picture/bullet3.png");
    //
    m_x=50;
    m_y=500;

    m_x_boss=0;
    m_y_boss=0;
    //
    m_free=true;
    m_free_boss=true;

    //
    m_rect.setWidth(m_Bullet1.width());
    m_rect.setHeight(m_Bullet1.height());
    m_rect.moveTo(m_x,m_y);

    m_rect_boss.setWidth(m_Bulletboss.width());
    m_rect_boss.setHeight(m_Bulletboss.height());
    m_rect_boss.moveTo(m_x_boss,m_y_boss);

    //
    m_speed=5;
    m_speed_boss=5;

    Bullet_interval=bullet_interval;

}

void bullet::updateposition1()
{
    if(m_free==true)
    {
        return;
    }
    else
    {
        m_y-=m_speed;
        m_rect.moveTo(m_x,m_y);
    }
    if(m_y<=-m_rect.height())
    {
        m_free=true;
    }

}

void bullet::updateposition2()
{
    if(m_free)
    {
        return;
    }
    else
    {
        m_y-=m_speed;
        m_x-=2;
        m_rect.moveTo(m_x,m_y);
    }
    if(m_y<=-m_rect.height()||m_x<=-m_rect.width())
    {
        m_free=true;
    }

}

void bullet::updateposition3()
{
    if(m_free)
    {
        return;
    }
    else
    {
        m_y-=m_speed;
        m_x+=2;
        m_rect.moveTo(m_x,m_y);
    }
    if(m_y<=-m_rect.height()||m_x>=Game_WIDTH)
    {
        m_free=true;
    }
}

void bullet::updatepositionboss()
{
    if(m_free_boss==true)
    {
        return;
    }
    else
    {
        m_y_boss+=m_speed;
        m_rect_boss.moveTo(m_x_boss,m_y_boss);
    }
}

